package com.ruoyi.lclook.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.lclook.domain.LcOnline;
import com.ruoyi.lclook.service.ILcOnlineService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 线上项目Controller
 * 
 * @author Choi
 * @date 2021-08-07
 */
@RestController
@RequestMapping("/lclook/online")
public class LcOnlineController extends BaseController
{
    @Autowired
    private ILcOnlineService lcOnlineService;

    /**
     * 查询线上项目列表
     */
    @PreAuthorize("@ss.hasPermi('lclook:online:list')")
    @GetMapping("/list")
    public TableDataInfo list(LcOnline lcOnline)
    {
        startPage();
        List<LcOnline> list = lcOnlineService.selectLcOnlineList(lcOnline);
        return getDataTable(list);
    }

    /**
     * 导出线上项目列表
     */
    @PreAuthorize("@ss.hasPermi('lclook:online:export')")
    @Log(title = "线上项目", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LcOnline lcOnline)
    {
        List<LcOnline> list = lcOnlineService.selectLcOnlineList(lcOnline);
        ExcelUtil<LcOnline> util = new ExcelUtil<LcOnline>(LcOnline.class);
        return util.exportExcel(list, "线上项目数据");
    }

    /**
     * 获取线上项目详细信息
     */
    @PreAuthorize("@ss.hasPermi('lclook:online:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(lcOnlineService.selectLcOnlineById(id));
    }

    /**
     * 新增线上项目
     */
    @PreAuthorize("@ss.hasPermi('lclook:online:add')")
    @Log(title = "线上项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LcOnline lcOnline)
    {
        return toAjax(lcOnlineService.insertLcOnline(lcOnline));
    }

    /**
     * 修改线上项目
     */
    @PreAuthorize("@ss.hasPermi('lclook:online:edit')")
    @Log(title = "线上项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LcOnline lcOnline)
    {
        return toAjax(lcOnlineService.updateLcOnline(lcOnline));
    }

    /**
     * 删除线上项目
     */
    @PreAuthorize("@ss.hasPermi('lclook:online:remove')")
    @Log(title = "线上项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(lcOnlineService.deleteLcOnlineByIds(ids));
    }
}
